home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / fx / Star.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  8.3 KB  |  318 lines

  1. class classes.fx.Star
  2. {
  3.    var sA;
  4.    var sO;
  5.    var sI;
  6.    var hv;
  7.    var hc;
  8.    var r = 8;
  9.    var hyper = false;
  10.    var hyper2 = false;
  11.    var make = true;
  12.    var Name = "star";
  13.    function Star()
  14.    {
  15.       this.sA = new Array();
  16.       this.sO = new Object();
  17.       this.sI = 0;
  18.    }
  19.    function deathHead()
  20.    {
  21.       this.r = 10;
  22.    }
  23.    function stopIt()
  24.    {
  25.       this.make = false;
  26.    }
  27.    function showPlanet(which)
  28.    {
  29.       this.sO["planet" + this.sI] = new Object();
  30.       var _loc3_ = this.sO["planet" + this.sI];
  31.       _loc3_.id = this.sI;
  32.       _loc3_.yMov = _root.randRange2(-0.3,-0.5);
  33.       if(which == "moon")
  34.       {
  35.          _loc3_.yMov = -1.2;
  36.       }
  37.       _root.d = _root.d + 1;
  38.       _loc3_.clip = _root.attachMovie("planets","planet" + this.sI + "Clip",_root.d - 5000);
  39.       _loc3_.clip._x = random(550) + 200;
  40.       _loc3_.clip._y = 755;
  41.       _loc3_.clip.gotoAndStop(which);
  42.       _loc3_.clip.cacheAsBitmap = true;
  43.       this.sA.push(_loc3_);
  44.       this.sI = this.sI + 1;
  45.    }
  46.    function hyperSpace(plvl)
  47.    {
  48.       var _loc4_ = plvl;
  49.       this.hv = _loc4_ != 2 ? 1.015 : 1.01;
  50.       this.hyper = _root.hyper = true;
  51.       this.hc = 0;
  52.       var _loc3_ = 0;
  53.       var _loc5_ = this.sA.length;
  54.       while(_loc3_ < _loc5_)
  55.       {
  56.          this.sA[_loc3_].clip.starClip.play("level" + _loc4_);
  57.          _loc3_ = _loc3_ + 1;
  58.       }
  59.    }
  60.    function endHyper()
  61.    {
  62.       this.hv = 1.005;
  63.       this.hyper2 = true;
  64.       this.hc = 0;
  65.       var _loc2_ = 0;
  66.       var _loc3_ = this.sA.length;
  67.       while(_loc2_ < _loc3_)
  68.       {
  69.          this.sA[_loc2_].clip.starClip.play("end");
  70.          _loc2_ = _loc2_ + 1;
  71.       }
  72.    }
  73.    function phase2()
  74.    {
  75.       this.r = 15;
  76.    }
  77.    function makeStars()
  78.    {
  79.       var _loc4_ = 0;
  80.       while(_loc4_ < 40)
  81.       {
  82.          this.sO["star" + this.sI] = new Object();
  83.          var _loc3_ = this.sO["star" + this.sI];
  84.          _loc3_.id = this.sI;
  85.          _loc3_.depth = random(9) + 1;
  86.          _loc3_.yMov = -1 * (_loc3_.depth / 2) * ((_root.level - 1) * 0.3 + 1);
  87.          _root.d = _root.d + 1;
  88.          _loc3_.clip = _root.attachMovie("star","star" + this.sI + "Clip",_root.d - 9000);
  89.          _loc3_.clip._x = random(1001);
  90.          _loc3_.clip._y = random(603);
  91.          _loc3_.clip._alpha = _loc3_.depth * 10;
  92.          _loc3_.clip.gotoAndStop(_root.randRange(_root.starColors[0],_root.starColors[1]));
  93.          this.sA.push(_loc3_);
  94.          this.sI = this.sI + 1;
  95.          _loc4_ = _loc4_ + 1;
  96.       }
  97.    }
  98.    function deleteAll()
  99.    {
  100.       var _loc3_ = 0;
  101.       var _loc5_ = this.sA.length;
  102.       while(_loc3_ < _loc5_)
  103.       {
  104.          var _loc4_ = this.sA[_loc3_];
  105.          _loc4_.clip.removeMovieClip();
  106.          _loc3_ = _loc3_ + 1;
  107.       }
  108.       _root.removeFX("star");
  109.    }
  110.    function main()
  111.    {
  112.       if(this.hyper)
  113.       {
  114.          this.r = 3;
  115.          this.hc = this.hc + 1;
  116.          if(this.hc < 120)
  117.          {
  118.             var _loc6_ = 0;
  119.             var _loc7_ = this.sA.length;
  120.             while(_loc6_ < _loc7_)
  121.             {
  122.                this.sA[_loc6_].yMov *= this.hv;
  123.                _loc6_ = _loc6_ + 1;
  124.             }
  125.          }
  126.          if(this.hc > 480)
  127.          {
  128.             _loc6_ = 0;
  129.             _loc7_ = this.sA.length;
  130.             while(_loc6_ < _loc7_)
  131.             {
  132.                this.sA[_loc6_].yMov /= this.hv;
  133.                _loc6_ = _loc6_ + 1;
  134.             }
  135.          }
  136.          if(this.hc == 560)
  137.          {
  138.             this.hyper = _root.hyper = false;
  139.             this.hc = 0;
  140.             this.r = 15;
  141.          }
  142.       }
  143.       if(this.hyper2)
  144.       {
  145.          this.r = 3;
  146.          this.hc = this.hc + 1;
  147.          if(this.hc < 240)
  148.          {
  149.             _loc6_ = 0;
  150.             _loc7_ = this.sA.length;
  151.             while(_loc6_ < _loc7_)
  152.             {
  153.                this.sA[_loc6_].yMov *= this.hv;
  154.                _loc6_ = _loc6_ + 1;
  155.             }
  156.          }
  157.          if(this.hc > 1560)
  158.          {
  159.             _loc6_ = 0;
  160.             _loc7_ = this.sA.length;
  161.             while(_loc6_ < _loc7_)
  162.             {
  163.                this.sA[_loc6_].yMov /= this.hv;
  164.                _loc6_ = _loc6_ + 1;
  165.             }
  166.          }
  167.          if(this.hc == 1800)
  168.          {
  169.             this.hyper2 = false;
  170.             this.hc = 0;
  171.             this.r = 15;
  172.          }
  173.       }
  174.       if(random(this.r - _root.level * 2) == 0 && this.make)
  175.       {
  176.          this.sO["star" + this.sI] = new Object();
  177.          var _loc4_ = this.sO["star" + this.sI];
  178.          _loc4_.id = this.sI;
  179.          _loc4_.depth = random(9) + 1;
  180.          _loc4_.yMov = -1 * (_loc4_.depth / 2) * ((_root.level - 1) * 0.3 + 1);
  181.          if(this.hyper)
  182.          {
  183.             if(this.hc < 120)
  184.             {
  185.                _loc6_ = 0;
  186.                do
  187.                {
  188.                   _loc4_.yMov *= this.hv;
  189.                   _loc6_ = _loc6_ + 1;
  190.                }
  191.                while(_loc6_ < this.hc);
  192.                
  193.             }
  194.             if(this.hc > 119)
  195.             {
  196.                _loc6_ = 0;
  197.                do
  198.                {
  199.                   _loc4_.yMov *= this.hv;
  200.                   _loc6_ = _loc6_ + 1;
  201.                }
  202.                while(_loc6_ < 120);
  203.                
  204.             }
  205.             if(this.hc > 559)
  206.             {
  207.                _loc6_ = 0;
  208.                do
  209.                {
  210.                   _loc4_.yMov /= this.hv;
  211.                   _loc6_ = _loc6_ + 1;
  212.                }
  213.                while(_loc6_ < this.hc - 560);
  214.                
  215.             }
  216.          }
  217.          if(this.hyper2)
  218.          {
  219.             if(this.hc < 240)
  220.             {
  221.                _loc6_ = 0;
  222.                do
  223.                {
  224.                   _loc4_.yMov *= this.hv;
  225.                   _loc6_ = _loc6_ + 1;
  226.                }
  227.                while(_loc6_ < this.hc);
  228.                
  229.             }
  230.             if(this.hc > 239)
  231.             {
  232.                _loc6_ = 0;
  233.                do
  234.                {
  235.                   _loc4_.yMov *= this.hv;
  236.                   _loc6_ = _loc6_ + 1;
  237.                }
  238.                while(_loc6_ < 240);
  239.                
  240.             }
  241.             if(this.hc > 1559)
  242.             {
  243.                _loc6_ = 0;
  244.                do
  245.                {
  246.                   _loc4_.yMov /= this.hv;
  247.                   _loc6_ = _loc6_ + 1;
  248.                }
  249.                while(_loc6_ < this.hc - 1560);
  250.                
  251.             }
  252.          }
  253.          _root.d = _root.d + 1;
  254.          _loc4_.clip = _root.attachMovie("star","star" + this.sI + "Clip",_root.d - 9000);
  255.          _loc4_.clip._x = random(1001);
  256.          _loc4_.clip._y = 603;
  257.          _loc4_.clip._alpha = _loc4_.depth * 10;
  258.          _loc4_.clip.gotoAndStop(_root.randRange(_root.starColors[0],_root.starColors[1]));
  259.          if(this.hyper)
  260.          {
  261.             var _loc8_ = this.hv != 1.015 ? 0 : 600;
  262.             _loc4_.clip.starClip.gotoAndPlay(this.hc + _loc8_);
  263.          }
  264.          else if(this.hyper2)
  265.          {
  266.             _loc4_.clip.starClip.gotoAndPlay(this.hc + 1400);
  267.          }
  268.          this.sA.push(_loc4_);
  269.          this.sI = this.sI + 1;
  270.       }
  271.       _loc6_ = 0;
  272.       _loc7_ = this.sA.length;
  273.       while(_loc6_ < _loc7_)
  274.       {
  275.          _loc4_ = this.sA[_loc6_];
  276.          _loc4_.clip._y += _loc4_.yMov;
  277.          if(_loc4_.clip._y < -5)
  278.          {
  279.             _loc4_.clip.removeMovieClip();
  280.             var _loc3_ = 0;
  281.             var _loc5_ = this.sA.length;
  282.             while(_loc3_ < _loc5_)
  283.             {
  284.                if(_loc4_ == this.sA[_loc3_])
  285.                {
  286.                   this.sA.splice(_loc3_,1);
  287.                }
  288.                _loc3_ = _loc3_ + 1;
  289.             }
  290.             delete this.sO["star" + _loc4_.id];
  291.          }
  292.          _loc6_ = _loc6_ + 1;
  293.       }
  294.       if(!this.make)
  295.       {
  296.          if(this.sA.length < 3)
  297.          {
  298.             _root.removeFX("star");
  299.          }
  300.       }
  301.       if(!this.make)
  302.       {
  303.          _loc6_ = 0;
  304.          _loc7_ = this.sA.length;
  305.          while(_loc6_ < _loc7_)
  306.          {
  307.             _loc4_ = this.sA[_loc6_];
  308.             _loc4_.yMov += 0.0075;
  309.             if(_loc4_.yMov > 0)
  310.             {
  311.                _loc4_.yMov = 0;
  312.             }
  313.             _loc6_ = _loc6_ + 1;
  314.          }
  315.       }
  316.    }
  317. }
  318.